package com.tongji.diy.model.furniturePlacementOptimization.assembleComplement
{
	public class Facal extends FurnitureBase
	{
		private var _SLlist:Vector.<SLbase> = new Vector.<SLbase>;//该list中的元素仅有furnitureClass是有效的，长宽高都是无效的，目的是为了有统一的接口形式所做的牺牲
		private var _correspondingNum:int = 0;
		private var _visibleDistance:Vector.<Number> = new Vector.<Number>;//按照前后左右的顺序排列
		private var _visibleOrientation:Vector.<Boolean> = new Vector.<Boolean>;//按照前后左右的顺序排列
		private var _correspondingNumVector:Vector.<int> = new Vector.<int>;
		
		
		public function Facal(furnitrueIndex:int, furnitureClass:int, aganistWall:Boolean, length:Number = 0, width:Number = 0, height:Number = 0, correspondingNumVector:Vector.<int> = null, SLpriorList:Vector.<SLbase> = null, visibleOrientation:Vector.<Boolean> = null, visibleDistance:Vector.<Number> = null)
		{
			super(furnitrueIndex, furnitureClass, aganistWall,length, width, height);
			_correspondingNumVector = correspondingNumVector;
			_correspondingNum = getCorrespondingNum();
			_SLlist = SLpriorList;
			_visibleOrientation = visibleOrientation;
			_visibleDistance = visibleDistance;
			if(furnitrueIndex != -1)//等于-1说明这只是个列表中的元素
				buildAccessibleBox();
		}
		
		private function getCorrespondingNum():int
		{
			if(_correspondingNumVector)
			{
				for(var i:int = 0; i < _correspondingNumVector.length; i++)
					_correspondingNum += _correspondingNumVector[i];

				return _correspondingNum;
			}
			else
				return 0;
		}
		
		override public function set angle(newAngle:Number):void
		{
			super.angle = newAngle;
			buildAccessibleBox();	
		}
		
		override public function set x(newX:Number):void
		{
			super.x = newX;
			buildAccessibleBox();		
		}
		
		override public function set y(newY:Number):void
		{
			super.y = newY;
			buildAccessibleBox();		
		}
		
		private function buildAccessibleBox():void
		{
			_accessibleBox = buildAccessOBB(x + (visibleDistance[3] - visibleDistance[2])/2,
				y + (-visibleDistance[0] + visibleDistance[1])/2,
				width + visibleDistance[2] + visibleDistance[3],
				length + visibleDistance[0] + visibleDistance[1]);
		}
		
		public function get SLlist():Vector.<SLbase>
		{
			return _SLlist;
		}
		
		public function get visibleOrientation():Vector.<Boolean>
		{
			return _visibleOrientation;
		}
		
		public function get visibleDistance():Vector.<Number>
		{
			return _visibleDistance;
		}
		
		public function get correspondingNum():int
		{
			return _correspondingNum;
		}
		
		public function get correspondingNumVector():Vector.<int>
		{
			return _correspondingNumVector;
		}		
	}
}